package dao.impl;

import dao.LoginDao;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import pojo.Admin;
import utils.JDBCUtils;

public class LoginDaoImpl implements LoginDao {
//    模板对象
private JdbcTemplate jt = new JdbcTemplate(JDBCUtils.getDs());
    @Override
    public Admin user(String username, String passwork) {
//       查询账户密码
        try {
//查询到
            String sql = "select * from tab_user where username=? and password=?";
            Admin admin = jt.queryForObject(sql, new BeanPropertyRowMapper<Admin>(Admin.class), username, passwork);
            return admin;
        } catch (Exception e) {
//            没查询到
            return null;
        }
    }
}
